from turtle import Turtle
from config import SCREEN_HEIGHT

class ScreenTable(Turtle):
    def __init__(self):
        super().__init__()
        self.r_score = 0
        self.l_score = 0
        self.color('white')
        self.penup()
        self.hideturtle()
        self.goto(0, SCREEN_HEIGHT / 2 - 30)
        self.update()

    def update(self):
        self.clear()
        self.goto(0, SCREEN_HEIGHT / 2 - 100)
        self.write(f"{self.l_score} : {self.r_score}", True, align="center", font=("Arial", 50, "normal"))
    
    def reset(self):
        self.r_score = 0
        self.l_score = 0
        self.update()
    
    def increase(self, paddle):
        if paddle == "r":
            self.r_score += 1
        elif paddle == "l":
            self.l_score += 1
        self.update()

    def game_over(self):
        self.goto(0, 0)
        self.write("GAME IS OVER", True, align="center", font=("Arial", 30, "normal"))

    def quit(self):
        self.goto(0, 0)
        self.write("Mouse click to exit", True, align="center", font=("Arial", 30, "normal"))
        
